package dao;

import dao.Entity.Student;
import dao.Entity.Students;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class QueryStudents {

    public static Students getResult() {
        Students res = null;
        MyConnection myCon = new MyConnection();
        myCon.getConnection();
        try {
            PreparedStatement ps = myCon.connection.prepareStatement(
                    "select studentaccount,BorrowCount,Defaults,borrowStatus from student");
            ResultSet rs = ps.executeQuery();
            res = new Students();
            while (rs.next()) {
                res.append(new Student(rs.getString(1), rs.getInt(2), rs.getInt(3), rs.getInt(4)));
            }
            ps.close();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myCon.closeConnection();
        }
        return res;
    }
}
